
import Api from './api'
import Address from './address'

const getUserCourse = async(page = 1) => {
  let url = Address.getUserCourse() + Address.getPageParams("?", page) + `&include=ratio`;
  let res = await Api.netFetch(url);
  if (res && res.result) {
    let data = res.data.data
    data.forEach((item) => {
      let ex = {
        name: item.name,
        image: item.image_path,
        ratio: item.ratio,
      }
      item.ex = ex
    });
    return {
      data: data,
      result: res.result
    };
  }
};

const getCourseDesc = async (id) => {
  let url = Address.getUserCourse() + `/${id}`
  let res = await Api.netFetch(url);
  if (res && res.result) {
    let data = res.data.data
    console.log(data)
    return {
      data: data,
      result: res.result
    };
  }

};


export default {
  getUserCourse,
  getCourseDesc,
}
